// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   designModule_draft_ok.java

package draft.manufacture;

import include.nseer_cookie.counter;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class designModule_draft_ok extends HttpServlet
{

	public designModule_draft_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		nseer_db_backup1 manufacture_db = new nseer_db_backup1(dbApplication);
		nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
		counter count = new counter(dbApplication);
		try
		{
			if (manufacture_db.conn((String)dbSession.getAttribute("unit_db_name")) && design_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String design_ID = request.getParameter("design_ID");
				String product_ID = request.getParameter("product_ID");
				String module_design_ID = "";
				String sql0 = (new StringBuilder("select * from design_module where product_ID='")).append(product_ID).append("' and check_tag='1'").toString();
				ResultSet rs0 = design_db.executeQuery(sql0);
				if (rs0.next())
					module_design_ID = rs0.getString("design_ID");
				String sql1 = (new StringBuilder("select * from design_module_details where design_ID='")).append(module_design_ID).append("' and design_balance_amount!='0'").toString();
				ResultSet rs2 = design_db.executeQuery(sql1);
				if (rs2.next())
				{
					response.sendRedirect((new StringBuilder("draft/manufacture/designModule_ok_a.jsp?design_ID=")).append(design_ID).toString());
				} else
				{
					String sql2 = "";
					sql2 = (new StringBuilder("update manufacture_design_procedure set design_module_change_tag='1' where design_ID='")).append(design_ID).append("'").toString();
					manufacture_db.executeUpdate(sql2);
					response.sendRedirect((new StringBuilder("draft/manufacture/designModule_ok_b.jsp?design_ID=")).append(design_ID).toString());
				}
				design_db.commit();
				manufacture_db.commit();
				design_db.close();
				manufacture_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
